package com.market.member.factory;

import com.block.common.util.ApplicationContextUtil;
import com.market.member.enums.AuthPlatformEnum;
import com.market.member.service.IAuthService;
import com.market.member.service.auth.AliAuthService;
import com.market.member.service.auth.DefaultAuthService;

import java.util.HashMap;
import java.util.Map;

public class AuthPlatformFactory {

    private static final Map<String, Class<? extends IAuthService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(AuthPlatformEnum.DEFAULT.getValue(), DefaultAuthService.class);
        serviceMap.put(AuthPlatformEnum.ALI.getValue(), AliAuthService.class);
    }

    public static IAuthService getService(String loginType){
        if (serviceMap.containsKey(loginType)){
            Class<? extends IAuthService> aClass = serviceMap.get(loginType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}